package com.briup.cms.web.controller;

import com.briup.cms.bean.Config;
import com.briup.cms.service.IConfigService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(description = "配置模块接口")
@RestController
@RequestMapping("/cms_config")
public class ConfigController {
    @Autowired
    private IConfigService configService;

  @ApiOperation("查询所有")
    @GetMapping("findAll")
    public Message findAll(){
      List<Config> config=configService.findAll();

    return  MessageUtil.success(config);
    }
   @ApiOperation("保存或更新")
@PostMapping("saveOrUpdate")
public Message saveOrUpdate(Config config){
  configService.saveOrUpdate(config);
  return  MessageUtil.success("操作成功");
  }
  @ApiOperation("删除记录")
    @PostMapping("deleteById")
    public Message deleteById (long id) {
      configService.deleteById(id);
      return MessageUtil.success("删除成功");
  }
}